home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / w00w00 / sectools / dsniff / decode_rlogin.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-16  |  974 b   |  48 lines

  1. /*
  2.   decode_rlogin.c
  3.  
  4.   Berkeley remote login/shell.
  5.   
  6.   Copyright (c) 2000 Dug Song <dugsong@monkey.org>
  7.  
  8.   $Id: decode_rlogin.c,v 1.1 2000/05/16 17:31:14 dugsong Exp $
  9. */
  10.  
  11. #include <sys/types.h>
  12. #include <stdio.h>
  13. #include <string.h>
  14. #include "options.h"
  15. #include "decode.h"
  16.  
  17. int
  18. decode_rlogin(u_char *buf, int len)
  19. {
  20.     char *p, *q;
  21.     
  22.     p = buf + 1;                /* Skip first NULL */
  23.     
  24.     strlcpy(Buf, "[", sizeof(Buf));
  25.     strlcat(Buf, p, sizeof(Buf));        /* Local username */
  26.     strlcat(Buf, ":", sizeof(Buf));
  27.     p += strlen(p) + 1;
  28.     
  29.     strlcat(Buf, p, sizeof(Buf));        /* Remote username */
  30.     strlcat(Buf, "]\n", sizeof(Buf));
  31.     p += strlen(p) + 1;
  32.     
  33.     p += strlen(p) + 1;            /* Skip term info */
  34.     
  35.     if ((q = strstr(p, "\xff\xffss")) != NULL)    /* Skip window size */
  36.         p += 12;
  37.     
  38.     for (p = strtok(p, "\r\n"); p != NULL; p = strtok(NULL, "\r\n")) {
  39.         strlcat(Buf, p, sizeof(Buf));
  40.         strlcat(Buf, "\n", sizeof(Buf));
  41.     }
  42.     if (!strip_lines(Buf, Opt_lines))
  43.         return (0);
  44.     
  45.     return (strlen(Buf));
  46. }
  47.  
  48.